package concurrency2;

public class StatusDemo {

    public static void main(String[] args) throws InterruptedException {
        Thread a = new Thread(StatusDemo::testMethod, "a");
        Thread b = new Thread(StatusDemo::testMethod, "b");

        a.start();
        Thread.sleep(1000);
        b.start();
        System.out.println(a.getName() + ":" + a.getState());
        System.out.println(b.getName() + ":" + b.getState());
    }

    private static synchronized void testMethod() {
        try {
            System.out.println(Thread.currentThread().getName() + "===in===");
            Thread.sleep(2000);
            System.out.println(Thread.currentThread().getName() + "===out===");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
